package com.strato.rpc.transport.http.v1_0_0;

import java.util.ArrayList;

import com.strato.mvc.api.v1_0_0.control.PathVariable;
import com.strato.mvc.api.v1_0_0.control.RequestMappingRegistry;
import com.strato.rpc.api.v1_0_0.Transport;

public abstract class HttpTransport implements Transport {

	private static String URL_PREFIX="/_strato_rpc_";
	
	@Override
	public void export(String path, Object object, Class<?> intf,String bundleName) {
		if(!path.startsWith("/")){
			path="/"+path;
		}
		RpcInvoker invoker=createInvoker(object,intf);
		RequestMappingRegistry.getInstance().addRequestMapping(getUrlPrefix()+path, new ArrayList<PathVariable>(), invoker);
	}

	public String getUrlPrefix(){
		return URL_PREFIX;
	}
	
	@Override
	public void unexport(String path) {
	}

	protected abstract RpcInvoker createInvoker(Object object, Class<?> intf);

}
